import { ref, reactive, computed } from "vue";
import { defineStore } from "pinia";

export const useUserDateStore = defineStore("user", () => {
    const getLocalStorage = () => {
        const res = {
            username: "",
            password: "",
            type: "common",
        };
        res.username = localStorage.getItem("username") || "";
        res.type = localStorage.getItem("type") || "common";
        return res;
    };

    const userData = reactive(getLocalStorage());
    const handleType = (value) => {
        userData.type = value;
    };
    return { userData, handleType };
});
